<?php
/**
 * Description of articles
 *
 * @author Dmitry
 */
class Controller_Articles extends Controller_Action {
  function index()
  {
    $this->registry->get('view')->show('allarticles');
  }
  
  function show($id)
  {
    $this->registry->get('view')->set('id',$id);
    $this->registry->get('view')->show('article');
  }
  
  function searche()
  {
    echo 'Results:';
    echo 'under construction!';
  }
  
  function showsub($id)
  {
    $this->registry->get('view')->set('id',$id);
    $this->registry->get('view')->show('subarticle');
  }
  
  function add()
  {
    $this->registry->get('view')->show('addarticle');
  }
  
  function adding()
  {
    $this->registry->get('view')->show('addingarticle');
  }
  
  function addsub()
  {
    $this->registry->get('view')->show('addsub'); 
  }
  
  function addingsub()
  {
      $this->registry->get('view')->show('addingsub'); 
  }
  
  function edit($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editarticle'); 
  }
  
  function editing($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editingarticle'); 
  }
  
  function editsub($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editsub'); 
  }
  
  function editingsub($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editingsub'); 
  }
  
  function anonces($item)
  {
      if($item == 'add')
      {
          $this->registry->get('view')->show('addanonce'); 
      } elseif($item == 'adding') {
          $this->registry->get('view')->show('addinganonce'); 
      } else {
          $this->registry->get('view')->show('allanonces'); 
      }
  }
  
  function editanonce($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editanonce'); 
  }
  
  function editinganonce($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editinganonce'); 
  }

  function anonce($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('anonce'); 
  }
  
  function tag($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('tag'); 
  }
  
  function addtag()
  {
      $this->registry->get('view')->show('addtag'); 
  }
  
  function addingtag()
  {
      $this->registry->get('view')->show('addingtag'); 
  }
  
  function editTag($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('edittag'); 
  }
  
  function editingTag($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('editingtag'); 
  }

  function tags()
  {
      $this->registry->get('view')->show('tags'); 
  }
  
  function addtagto($id)
  {
      if(isset($_POST['add']) or isset($_POST['remove']))
      {
          $this->registry->get('view')->set('tagId',$_POST['tag']);
      }
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('addtagto'); 
  }
  
  function permission($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('permissions'); 
  }
  
  function subpermisiion($id)
  {
      $this->registry->get('view')->set('id',$id);
      $this->registry->get('view')->show('subpermissions'); 
  }
}